package com.example.redistest;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
public class Controller {
    @Resource(name = "redisTemplateSelf")
    private RedisTemplate<String,Object> redisTemplate;

    @RequestMapping("/test")
    public Integer test() {
        log.info("increment num");
        redisTemplate.opsForValue().increment("num");
        return (Integer) redisTemplate.opsForValue().get("num");
    }
}
